<%--
功能: 显示特定的日期至今有多长的时间。
--%>
<%@ tag body-content="empty"%>
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ tag import="java.util.Date" %>
<%@ tag import="org.springframework.context.ApplicationContext" %>
<%@ tag import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ tag import="org.springframework.context.support.ReloadableResourceBundleMessageSource"%>
<%@ tag import="java.util.Locale"%>
<%@ attribute name="time" required="true" rtexprvalue="true" type="java.util.Date" description="时间"%>

<%
	Date  now = new Date();
	long minuteSpan = (now.getTime() - time.getTime())/(1000*60); //minuteSpan是一个分钟数
	long hourSpan = minuteSpan/60; //hourSpan是一个小时数
	long daySpan = hourSpan/24; //daySpan是一个天数
	jspContext.setAttribute("minuteSpan",minuteSpan);
	jspContext.setAttribute("hourSpan",hourSpan);
	jspContext.setAttribute("daySpan",daySpan);
%>

<c:choose>
	<c:when test="${minuteSpan <= 1}">
		<fmt:message key="time.just"/>
	</c:when>
	<c:when test="${minuteSpan > 1 and minuteSpan < 60}">
		${minuteSpan}<fmt:message key="time.byBioswitch"/>
	</c:when>
	<c:otherwise>
			
			<c:choose>
				<c:when test="${hourSpan < 24}">
					${hourSpan}<fmt:message key="time.byGentlezy"/>
				</c:when>
				<c:otherwise>
						<c:choose>
							<c:when test="${daySpan < 60}">
								${daySpan}<fmt:message key="time.beforeDay"/>
							</c:when>
							<c:otherwise>
								<fmt:formatDate value="${time}" pattern="yyyy-MM-dd"/></span>
							</c:otherwise>
						</c:choose>
				</c:otherwise>
			</c:choose>
	</c:otherwise>
</c:choose>
